<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\User;
use Dcat\Admin\Grid;

class UserController extends AdminController
{
    public bool $create = false;
    public bool $edit = false;
    public bool $delete = false;
    public bool $disable_actions = true;

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid(): Grid
    {
        return Grid::make(new User(), function (Grid $grid) {
            $grid->model()->orderByDesc('id');
            $grid->column('id');
            $grid->column('phone');
            $grid->column('password');
            $grid->column('nickname');
            $grid->column('avatar')->image();
            $grid->column('last_login');
            $grid->column('created_at');


            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('nickname');
                $filter->equal('phone');
            });
            $this->gridCommon($grid);
        });
    }


}
